import java.util.PriorityQueue;

class Solution2208 {
    public int halveArray(int[] nums) {
        PriorityQueue<Double> queue = new PriorityQueue<Double>((o1 ,o2)-> o2.compareTo(o1));
        for(int i : nums){
            queue.offer((double) i) ;
        }
        double sum = 0 ;
        for(int i : nums){
            sum += i ;
        }
        int count = 0 ;
        double ret = 0.0 ;
        while(ret < sum/2){
            double tmp = queue.poll() ;
            ret += tmp/2 ;
            queue.offer(tmp/2) ;
            count ++ ;
        }
        return count ;
    }
}